package com.csi.jf.crucible.ptservice.service.impl;


import com.chinasofti.ro.bizframework.core.orm.Page;
import com.chinasofti.ro.bizframework.core.orm.entity.Model;
import com.chinasofti.ro.bizframework.core.orm.IDAO;
import com.csi.jf.crucible.ptservice.model.*;
import com.csi.jf.crucible.ptservice.service.*;

/**
 * <p>ServiceImpl</p>
 * 
 * @author BizFoundation
 * @version 1.0
 * @since 1.0
 */
public class CruReviewsServiceImpl implements CruReviewsService {

	private IDAO dao;
	
	public void setDao(IDAO dao) {
		this.dao = dao;
	}

	/**
	 * 根据id查询数据
	 * 
	 * @param id
	 * @return Model
	 */
	public Model findById(Long id) {
		CruReviews reviewCru = new CruReviews();
		reviewCru.setId(id);
		return (Model) dao.createQuery(reviewCru).first();
	}
	
	/**
	 * 分页查询
	 * 
	 * @param cruReviews
	 * @param page 分页
	 * @return
	 */
	public Page findByPage(CruReviews cruReviews, Page page) {
		String sql = cruReviews.getSql("list", dao.dbMeta());//使用reviewCru.hbm.xml中的id为list的sql查询
		return dao.createNamedQuery(cruReviews.getClass(),sql, cruReviews).fetch(page);
	}
	
	/**
	 * 批量删除数据
	 * 
	 * @param ids
	 * @return int[] delete records
	 */
	public int[] batchDelete(String ids) {
		CruReviews reviewCru = new CruReviews();
		return dao.batchDelete(reviewCru, ids);
	}

	/**
	 * 保存数据
	 * @param Model
	 */
	public void save(Model model) {
		dao.save(model);
	}

	/**
	 * 更新数据
	 * @param Model
	 */
	public void update(Model model) {
		dao.update(model);
	}
}